package com.smsc.headend.task.engine;

import com.smsc.headend.common.utils.SpringContextUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.kafka.config.KafkaListenerEndpointRegistry;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
//@SpringBootApplication
@Configuration
@ComponentScan(basePackages = {"com.smsc.headend.common", "com.smsc.headend.task"}
//, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {ShardingDataConfig.class})
)
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan("com.smsc.headend.task.engine.mapper")
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableAsync
public class TaskEngineApplication {


    public static void main(String[] args) {
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry = SpringContextUtils.getBean(KafkaListenerEndpointRegistry.class);
                kafkaListenerEndpointRegistry.stop();
            }
        });
        SpringApplication.run(TaskEngineApplication.class, args).registerShutdownHook();
    }


}
